import request from '@/utils/request'

// 获取所有角色
export function getRoles() {
  return request({
    url: '/admin/roles',
    method: 'get'
  })
}

// 获取角色详情
export function getRole(id) {
  return request({
    url: `/admin/roles/${id}`,
    method: 'get'
  })
}

// 创建角色
export function createRole(data) {
  return request({
    url: '/admin/roles',
    method: 'post',
    data
  })
}

// 更新角色
export function updateRole(id, data) {
  return request({
    url: `/admin/roles/${id}`,
    method: 'put',
    data
  })
}

// 删除角色
export function deleteRole(id) {
  return request({
    url: `/admin/roles/${id}`,
    method: 'delete'
  })
}

// 获取角色权限
export function getRolePermissions(id) {
  return request({
    url: `/admin/roles/${id}/permissions`,
    method: 'get'
  })
}

// 更新角色权限
export function updateRolePermissions(id, permissions) {
  return request({
    url: `/admin/roles/${id}/permissions`,
    method: 'put',
    data: { permissions }
  })
} 